<template>
  <div class>
    <h3 :style="'background-color:'+$store.state.color">
      未完成
      <span @click="num=!num">=</span>
    </h3>
    <ul v-show="num==0">
      <li v-for="(item,index) in this.$store.state.list" :key="index" v-show="item.num==0">
        <input type="checkbox" @click.prevent="change1(index)" />
        <span>{{item.title}}</span>
        <button @click="del(index)">取消</button>
      </li>
    </ul>

    <h3 :style="'background-color:'+$store.state.color">
      已完成
      <span @click="num1=!num1">=</span>
    </h3>
    <ul v-show="num1==1">
      <li v-for="(item,index) in this.$store.state.list" :key="index" v-show="item.num==1">
        <input type="checkbox" checked @click.prevent="change2(index)" />
        <span>{{item.title}}</span>
        <span>{{item.time}}</span>
        <button @click="del(index)">取消</button>
      </li>
    </ul>

    <h3 :style="'background-color:'+$store.state.color">
      回收站
       <span @click="num2=!num2">=</span>
    </h3>
    <ul v-show="num2==false">
      <li v-for="(item,index) in this.$store.state.list" :key="index" v-show="item.num==2">
        <s>{{item.title}}</s>
        <button @click.prevent="change3(index)">恢复</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
        num:0,
        num1:1,
        num2:false,
    };
  },
  mounted() {},
  methods: {
    change1(index) {
      this.$store.state.list[index].num = 1;
    },
    change2(index) {
      this.$store.state.list[index].num = 0;
    },
    change3(index) {
      this.$store.state.list[index].num = 0;
    },
    del(index) {
      this.$store.state.list[index].num = 2;
    }
  }
};
</script>

<style lang='scss' scoped>
ul {
  width: 100%;

  li {
    display: flex;
    justify-content: space-around;
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid rgb(233, 233, 233);
    input {
      margin-top: 7px;
    }
  }
}

h3 {
  width: 100%;
  height: 50px;
  background-color: rgb(0, 0, 0);
  color: white;
  line-height: 50px;
}
</style>
